package org.mobilesynergies.epic.client;

import java.util.*;

import org.jivesoftware.smack.packet.PacketExtension;
import org.mobilesynergies.epic.client.remoteui.Parameter;
import org.mobilesynergies.epic.client.remoteui.ParameterMap;



/**
 * Implementation of the EpicPacketExtension. 
 * 
 * @author Peter Rautek
 */

public class EpicPacketExtension implements PacketExtension{

	public static final String ELEMENTNAME = "application";
    public static final String NAMESPACE = "http://mobilesynergies.org/protocol/epic";
    
    private ParameterMap mData;
    private String mReceiver;
    
    public EpicPacketExtension(ParameterMap data, String receiver){
    	mData = data;
    	mReceiver = receiver;
    }

     /**
     * Returns the XML element name of the extension sub-packet root element.
     * @return the XML element name of the packet extension.
     */
    public String getElementName() {
        return ELEMENTNAME;
    }

    /**
     * Returns the XML namespace of the extension sub-packet root element.
     *
     * @return the XML namespace of the packet extension.
     */
    public String getNamespace() {
        return NAMESPACE;
    }
    
    /**
     * Returns the XML namespace of the extension sub-packet root element.
     *
     * @return the XML namespace of the packet extension.
     */
    public String getReceiver() {
        return mReceiver;
    }

    public String toXML() {
        StringBuilder buf = new StringBuilder();
        buf.append("<").append(ELEMENTNAME).append(" xmlns=\"").append(NAMESPACE).append("\" to=\"").append(mReceiver).append("\">");
        buf.append(mData.contentAsXml());
        buf.append("</").append(ELEMENTNAME).append(">");
        return buf.toString();
    }

   

}